package com.caipiao.util.db;

/**
 * @author GaoFeng
 */

import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;

public class DBOutCursor
{
	private CachedRowSet rs = null;
	
	public void finalize()
	{
		if (null != this.rs)
		{
			try
			{
				rs.close();
			}
			catch (SQLException e)
			{
			}
		}
	}
	
	public DBOutCursor()
	{
		this.rs = null;
	}
	
	public DBOutCursor(CachedRowSet rs)
	{
		this.rs = rs;
	}
	
	public CachedRowSet toResultSet()
	{
		return rs;
	}
	
	public void setResultSet(CachedRowSet rs)
	{
		this.rs = rs;
	};
	
	public boolean IsEmpty()
	{
		return this.rs == null;
	}
	
	public String getString(String name)
	{ 
		try
		{
			String value =  this.rs.getString(name);
			if (null == value || value.equalsIgnoreCase("N/A"))
			{
				return "";
			}
			
			return value;
		}
		catch(Exception e)
		{
			return "";
		}
	}
	
	public String getSrcString(String name)
	{ 
		try
		{
			return  this.rs.getString(name);
		}
		catch(Exception e)
		{
			return "";
		}
	}
	
	public boolean next()
	{
		try
		{
			return this.rs.next();
		}
		catch(Exception e)
		{
			return false;
		}
	}
}
